Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check invalid elements in <Blocks> and <Input> strictly #64

Merged
merged 6 commits into from
Oct 1, 2019

Conversation

yhatt
Copy link
Owner

@yhatt yhatt commented Oct 1, 2019

By adding input-compatible props to existed interactive components (#63), the possibility of wrong usage would increase. For example, using label prop at interactive components in <Blocks> and <Actions> would not be thrown error but outputs invalid JSON when sending to Slack.

For helping user to notice mistake, we've refactored JSX parse logic and added after-parse validation to <Blocks> and <Input>.

Especially these were hard to check rendered elements if is used multi-level <Fragment>, so we changed internal JSX object to allow defining event function called at after parsed as internal props. Thereby we can validate to the final output of JSON.

@@ -18,13 +20,16 @@ export interface ParseContext {
mode: ParseMode
}

export function JSXSlack(
node: JSXSlack.Node,
context: ParseContext = {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An exported JSXSlack no longer have second argument for private use. We updated to use this in internal parseJSX function.

@yhatt yhatt merged commit 5caeaaa into master Oct 1, 2019
@yhatt yhatt deleted the check-invalid-element-strictly branch October 1, 2019 05:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant